package ws;

import java.rmi.RemoteException;

import ws_pkg.EntregaSituacao;
import ws_pkg.PrazoFrete;
import ws_pkg.Produto;
import ws_pkg.Transportadora;
import ws_pkg.WsPortType;
import ws_pkg.WsLocator;

public class WsPortTypeProxy implements WsPortType {
  private String _endpoint = null;
  private WsPortType wsPortType = null;
  
  public WsPortTypeProxy() {
    _initWsPortTypeProxy();
  }
  
  public WsPortTypeProxy(String endpoint) {
    _endpoint = endpoint;
    _initWsPortTypeProxy();
  }
  
  private void _initWsPortTypeProxy() {
    try {
      wsPortType = (new WsLocator()).getwsPort();
      if (wsPortType != null) {
        if (_endpoint != null)
          ((javax.xml.rpc.Stub)wsPortType)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        else
          _endpoint = (String)((javax.xml.rpc.Stub)wsPortType)._getProperty("javax.xml.rpc.service.endpoint.address");
      }
      
    }
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  
  public String getEndpoint() {
    return _endpoint;
  }
  
  public void setEndpoint(String endpoint) {
    _endpoint = endpoint;
    if (wsPortType != null)
      ((javax.xml.rpc.Stub)wsPortType)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
    
  }
  
  public WsPortType getWsPortType() {
    if (wsPortType == null)
      _initWsPortTypeProxy();
    return wsPortType;
  }

@Override
public Transportadora[] listarTransportadoras(String transportadora)
		throws RemoteException {
	 if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.listarTransportadoras(transportadora);
}

@Override
public PrazoFrete calculaFreteEPrazo(int cep_remetente, int cep_destinatario,
		int id_transportadora, Produto[] produtos) throws RemoteException {
	 if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.calculaFreteEPrazo(cep_remetente, cep_destinatario, id_transportadora, produtos);
}

@Override
public int cadastrarEntrega(int id_portal, int cep_remetente,
		int cep_destinatario, int id_transportadora, Produto[] produtos)
		throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.cadastrarEntrega(id_portal, cep_remetente, cep_destinatario, id_transportadora, produtos);
}

@Override
public boolean cancelarEntrega(int id_entrega) throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.cancelarEntrega(id_entrega);
}

@Override
public String consultarEntrega(int id_entrega) throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.consultarEntrega(id_entrega);
}

@Override
public int[] consultarEntregasPortal(String id_portal) throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.consultarEntregasPortal(id_portal);
}

@Override
public String atualizarEntrega(int id_entrega) throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.atualizarEntrega(id_entrega);
}

@Override
public EntregaSituacao[] consultarRelatorioSituacaoEntrega(int id_entrega)
		throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.consultarRelatorioSituacaoEntrega(id_entrega);
}

@Override
public Produto[] consultarProdutosEntrega(int id_entrega)
		throws RemoteException {
	if (wsPortType == null)
	      _initWsPortTypeProxy();
	 return wsPortType.consultarProdutosEntrega(id_entrega);
}
  
  
}